package com.xbongbong.saas.enums.dictionary;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * @author ruansicheng
 * @className KnowledgeDataStatusEnum
 * @description
 * @date 2022/06/29   14:41
 */
@Getter
public enum KnowledgeDataStatusEnum {
    // 知识条目状态

    ENABLE(0, "enum.knowledgeDataStatus.name.enable", "enable"),
    BLOCK_UP(1, "enum.knowledgeDataStatus.name.block_up", "disable"),
    ;

    private Integer code;
    private String name;
    private String attr;

    KnowledgeDataStatusEnum(Integer code, String name, String attr) {
        this.code = code;
        this.name = name;
        this.attr = attr;
    }


    public static String getByCode(Integer number) {
        for (KnowledgeDataStatusEnum knowledgeDataStatusEnum : values()) {
            if (Objects.equals(knowledgeDataStatusEnum.getCode(), number)) {
                return knowledgeDataStatusEnum.getName();
            }
        }
        return "";
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
